import Vue from 'vue'
import './plugins/axios'
import './plugins/fontawesome'
import App from './App.vue'
import router from './router'
import i18n from './lang'
import './lazy'
import store from '../src/store/index'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css'
import '@/assets/styles/global.scss'
import '@/assets/styles/icon.css'




Vue.use(ElementUI);
Vue.config.productionTip = false

router.beforeEach((to,from,next)=>{
  const needLogin = to.matched.some(route=>route.meta && route.meta.login)
  if(needLogin){
    const isLogin = document.cookie.includes('login=true');
    if(isLogin){
      next();
      return;
    }
    const goLogin = window.confirm('该页面需要登录才可访问，是否去登陆');

    if(goLogin) {
      next('/Adminster')
    }return;
  }
  next()
})

new Vue({
  router,
  store,
  i18n,

  render: h => h(App)
}).$mount('#app')
